using PKGames.MiniGames.VoxelGame.Scripts.World;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

namespace PKGames.MiniGames.VoxelGame.UI.GameUI.Scripts
{
	public class MultiFunctionButtonsController : MonoBehaviour
	{
		[SerializeField]
		private Button _leftCornerButton;

		[SerializeField]
		private Button _rightCornerButton;

		[SerializeField]
		private GameObject _leftButtonHolder;

		[SerializeField]
		private GameObject _rightButtonHolder;

		[SerializeField]
		private Image _leftCornerButtonImage;

		[SerializeField]
		private Image _rightCornerButtonImage;

		[SerializeField]
		private Sprite _pauseButtonSprite;

		[SerializeField]
		private Sprite _playButtonSprite;

		[SerializeField]
		private Sprite _homeButtonSprite;

		public void Setup(UnityAction leftCornerButtonAction, UnityAction rightCornerButtonAction)
		{
			_leftCornerButton.onClick.RemoveAllListeners();
			_leftCornerButton.onClick.AddListener(leftCornerButtonAction);
			_rightCornerButton.onClick.RemoveAllListeners();
			_rightCornerButton.onClick.AddListener(rightCornerButtonAction);
			_rightCornerButtonImage.sprite = _homeButtonSprite;
		}

		public void SetButtonSkinsAccordingToState(UiController.UiState uiState)
		{
			switch (uiState)
			{
			case UiController.UiState.AllWindowsClosed:
				_leftButtonHolder.SetActive(value: true);
				_rightButtonHolder.SetActive(value: false);
				_leftCornerButtonImage.sprite = _pauseButtonSprite;
				break;
			case UiController.UiState.SettingsOpen:
				_rightButtonHolder.SetActive(value: false);
				_leftCornerButtonImage.sprite = _playButtonSprite;
				break;
			case UiController.UiState.IapCreativeOpenAnimation:
				_rightButtonHolder.SetActive(value: true);
				_leftCornerButtonImage.sprite = _playButtonSprite;
				break;
			case UiController.UiState.IapCreativeForceOpenAnimation:
				_rightButtonHolder.SetActive(value: true);
				_leftButtonHolder.SetActive(value: false);
				break;
			}
		}
	}
}
